package com.feeyin.radar.crm.dao.impl;

import com.feeyin.radar.commons.Page;
import com.feeyin.radar.crm.dao.CustomerUpdateHistoryDAO;
import com.feeyin.radar.crm.model.Customer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.orm.ibatis.SqlMapClientTemplate;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class CustomerUpdateHistoryDAOImpl extends SqlMapClientDaoSupport
  implements CustomerUpdateHistoryDAO
{
  public List getPageCustomerUpdateHistorysByCustomerId(Integer customerId, Page page)
  {
    Map map = new HashMap();
    map.put("customerId", customerId);
    map.put("pageStartRow", Integer.valueOf(page.getPageStartRow()));
    map.put("pageEndRow", Integer.valueOf(page.getPageEndRow()));
    return getSqlMapClientTemplate().queryForList("getPageCustomerUpdateHistorysByCustomerId", map);
  }

  public Integer getPageCustomerUpdateHistorysCountByCustomerId(Integer customerId)
  {
    return (Integer)getSqlMapClientTemplate().queryForObject("getPageCustomerUpdateHistorysCountByCustomerId", customerId);
  }

  public Customer getCustomerUpdateHistory(Integer id)
  {
    return (Customer)getSqlMapClientTemplate().queryForObject("getCustomerUpdateHistory", id);
  }

  public boolean insertCustomerUpdateHistory(Customer customer) {
    if ((customer == null) || (customer.getCustomerId() == null)) return false;
    Integer result = (Integer)getSqlMapClientTemplate().insert("insertCustomerUpdateHistory", customer);
    return result != null;
  }
}